package dao

import (
	"context"
	"system-admin/internal/dal"
	"system-admin/internal/models"
)

type Merchant struct{}

// Detail 商户详情
func (Merchant) Detail(
	ctx context.Context,
	query *dal.Query,
	merchantID string,
) (*models.Merchant, error) {
	m := query.Merchant
	return m.WithContext(ctx).Where(m.ID.Eq(merchantID)).Take()
}

// ListByMerchantPath 获取用户列表，通过商户路径
func (Merchant) ListByMerchantPath(
	ctx context.Context,
	query *dal.Query,
	merchantPath string,
) ([]*models.Merchant, error) {
	m := query.Merchant
	return m.WithContext(ctx).Where(m.MerchantPath.Like(merchantPath + "%")).Find()
}
